//
//  SchoolHeadView.swift
//  KaMengApplication
//
//  Created by DUONIU_MAC on 2018/10/23.
//  Copyright © 2018年 DUONIU_MAC. All rights reserved.
//

import UIKit

class SchoolHeadView: UIView {
    
    var image : String!{
        didSet{
            
            if image == nil {
                imageView.image = UIImage.imageWithName("loading")
            }else{
                imageView.setUrlImage(with: kmHttps + image, placeholder: UIImage.imageWithName("loading"))
            }
            
        }
    }
    
    var text : String! {
        didSet{
            textLabel.text = text
        }
    }
    
    fileprivate let imageView = UIImageView()
    fileprivate let textLabel = UITextView()

    init() {
        super.init(frame: .zero)
        
        imageView.image = UIImage.imageWithName("loading")
        self.addSubview(imageView)
        
        textLabel.font = UIFont.systemFont(ofSize: RATIO(maxNum: 14))
        textLabel.isEditable = false
        self.addSubview(textLabel)
        
        imageView.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(RATIO(maxNum: 20))
            make.centerY.equalToSuperview()
            make.width.equalTo(RATIO(maxNum: 150))
            make.height.equalTo(RATIO_H(maxNum: 100))
        }
        
        textLabel.snp.makeConstraints { (make) in
            make.left.equalTo(imageView.snp.right).offset(RATIO(maxNum: 10))
            make.centerY.equalToSuperview().offset(RATIO_H(maxNum: -5))
            make.right.equalToSuperview().offset(RATIO(maxNum: -20))
            make.height.equalTo(RATIO_H(maxNum: 110))
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
